package net.hanjava.swing;

import java.awt.Color;
import java.awt.Graphics;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

@SuppressWarnings("serial")
public class Alpha2 extends JLabel {
	public static final Color TRANSCLUENT_BLACK = new Color(0f, 0f, 0f, 0.5f);

	public Alpha2(String imgurl) throws MalformedURLException {
		URL url = new URL(imgurl);
		ImageIcon icon = new ImageIcon(url);
		setIcon(icon);
	}

	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);

		g.setColor(TRANSCLUENT_BLACK);
		int w = getWidth();
		int h = getHeight();
		g.fillRect(0, 0, w / 2, h);
	}

	public static void main(String[] args) throws MalformedURLException {
		JLabel label = new Alpha2(Alpha1.URL_ICON);
		Util.show(label);
	}
}